#include<iostream>
#include<cstdio>
#define N 200005
using namespace std;
struct node{
	int l,r,val,nxt;
}e[N];
int n,tot,suf[N],pre[N],en;
void print(){
	bool flag=0;
	for(int i=1;i!=tot+1;i=e[i].nxt){
		if(e[i].l>e[i].r) continue;
		flag=1;
		printf("%d ",e[i].l);
		suf[pre[e[i].l]]=suf[e[i].l];
		pre[suf[e[i].l]]=pre[e[i].l];
	}
	if(!flag){
		en=1;
		return;
	}
	for(int i=1;i!=tot+1;i=e[i].nxt){
		if(e[i].l>e[i].r) continue;
		e[i].l=suf[pre[e[i].l]];
	}
	printf("\n");
}
void toge(int x,int &i){
	i=max(i,x);
	int v=e[x].nxt;
	if(v!=tot+1){
		toge(v,i);
		if(e[v].l>e[v].r){
			e[x].nxt=e[v].nxt;
			if(e[x].val==e[e[x].nxt].val&&e[x].nxt!=tot+1){
				e[x].r=e[e[x].nxt].r;
				e[x].nxt=e[e[x].nxt].nxt;
			}
		}
	}
	return;
}
int main(){
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	scanf("%d",&n);
	int l=1,r=0,val=-1;
	for(int i=1;i<=n;i++){
		suf[i]=i+1;
		pre[i]=i-1;
		int x;
		scanf("%d",&x);
		if(x!=val){
			if(val!=-1){
				tot++;
				e[tot]=(node){l,r,val,tot+1};
			}
			val=x;
			l=i,r=i;
		}else{
			r++;
		}
	}
	tot++;
	e[tot]=(node){l,r,val,tot+1};
	while(true){
		print();
		if(en) break;
		for(int i=1;i!=tot+1;i=e[i].nxt){
			if(e[i].l<=e[i].r){
				toge(i,i);
			}
		}
	}
}
